package com.dou.sample.baserecycleradapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Dou on 2018/1/10.
 */

public abstract class MultiItemCommenAdapter<T> extends CommenAdapter<T> {

    MultiItemSupport<T> mMultiItemSupport;

    public MultiItemCommenAdapter(Context context, List<T> data, MultiItemSupport<T> multiItemSupport) {
        super(context, -1, data);
        mContext = context;
        mData = data;
        mMultiItemSupport = multiItemSupport;
    }

    @Override
    public int getItemViewType(int position) {
        return mMultiItemSupport.getItemType(position, mData.get(position));
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        super.onCreateViewHolder(parent, viewType);
        View view = LayoutInflater.from(mContext).inflate(mMultiItemSupport.getLayoutId(viewType), parent);
        return new ViewHolder(mContext, view);
    }
}
